﻿#include "Generation/Piecemeal/Rect_Iterator.h"
#include "Generation/Piecemeal/Rect.h"

FRect_Iterator::FRect_Iterator(FRect& rect, int constructType)
{
	m_Rect = &rect;

	if (constructType == 0)
	{
		x = m_Rect->x();
		y = m_Rect->y();
	}
	else if (constructType == 1)//越界的构造	
		{
		x = m_Rect->x();
		y = m_Rect->bottom();
		}

	m_Ptr = new FVec(x, y);
}

FRect_Iterator::reference FRect_Iterator::operator*()
{
	// UE_LOG(LogTD, Error, TEXT("Get %d %d"), (*m_Ptr).x, (*m_Ptr).y);
	return *m_Ptr;
}

FRect_Iterator& FRect_Iterator::operator++()
{
	x++;
	if (x == m_Rect->right()) // x:0 right:50 get:0-49
		{
		x = m_Rect->x();
		y++;
		}

	// UE_LOG(LogTD, Error, TEXT("x++ %d %d"), x, y);
	
	m_Ptr->Set(x, y);

	return *this;
}